<!--
  -    Copyright (c) 2018-2025, lengleng All rights reserved.
  -
  - Redistribution and use in source and binary forms, with or without
  - modification, are permitted provided that the following conditions are met:
  -
  - Redistributions of source code must retain the above copyright notice,
  - this list of conditions and the following disclaimer.
  - Redistributions in binary form must reproduce the above copyright
  - notice, this list of conditions and the following disclaimer in the
  - documentation and/or other materials provided with the distribution.
  - Neither the name of the pig4cloud.com developer nor the names of its
  - contributors may be used to endorse or promote products derived from
  - this software without specific prior written permission.
  - Author: lengleng (wangiegie@gmail.com)
  -->
<template>
    <div class="execution">
        <basic-container>
             <avue-form
                ref="form"
                v-loading="loading"
                v-model="form"
                :option="tableOption"
                @reset-change="resetForm"
                @submit="submitForm"
            >
      </avue-form>
        </basic-container>
    </div>
</template>

<script>
    import {fetchList, getObj, addObj, putObj, delObj} from '@/api/circleexaminationset'
    import {tableOption} from '@/const/crud/circleexaminationset'
    import {mapGetters} from 'vuex'

    export default {
        name: 'circleexaminationset',
        data() {
            return {
                form:{
                },
                searchForm: {},
                tableData: [],
                page: {
                    total: 0, // 总页数
                    currentPage: 1, // 当前页数
                    pageSize: 20 // 每页显示多少条
                },
                tableLoading: false,
                tableOption: tableOption
            }
        },
        watch:{
             "form.isRepeat": {
                  handler(val) {
                    var number = this.findObject(this.tableOption.column, "number");
                    if(val == 1){
                        number.display = true
                    }
                    if(val == 2) {
                        number.display = false
                    }
                  }
             }
        },
        computed: {
            ...mapGetters(['permissions']),
            permissionList() {
                return {
                    addBtn: this.vaildData(this.permissions.circleExaminationSet_circleexaminationset_add, false),
                    delBtn: this.vaildData(this.permissions.circleExaminationSet_circleexaminationset_del, false),
                    editBtn: this.vaildData(this.permissions.circleExaminationSet_circleexaminationset_edit, false)
                };
            }
        },
        mounted() {
            this.getList();
        },
        methods: {
            getList(){
                var vm = this
                getObj(1).then(res => {
                    var info = res.data.data;
                    vm.form = info;
                })
            },
          //表单提交
            submitForm(form, done) {
            this.$refs.form.validate((vaild) => {
                if (vaild) {
                /* var form = JSON.parse(JSON.stringify(this.form));
                form.leader = JSON.stringify(form.leader); */
                putObj(form).then(res => {
                    this.$message.success("保存成功");
                    done()

                })
                }
            })
            },

            //表单重置
            resetForm() {
                this.$refs.form.resetForm();
            },
        }
    }
</script>
